# -*- mode: snippet -*-
# contributor: Chen Bin <chenbin DOT sh AT gmail>
# name: <html> angular+angular-ui+bootstrap
# key: html5
# --
<!DOCTYPE html>
<html ng-app="${2:$(yas/substr yas-text "[^ ]*")}">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="" />
    <title>Angular Sandbox (with Bootstrap)</title>
    <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.13/angular.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.13/angular-route.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.13/angular-mocks.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.0/ui-bootstrap-tpls.min.js"></script>
    <link type="text/css" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css" />
    <style type="text/css">.nav, .pagination, .carousel, .panel-title a { cursor: pointer; } /* angular ui bootstrap hack */</style>
  </head>
  <body>
    <div class="container" ng-controller="MainCtrl">
      <h1>{{message}}</h1>
    </div>
    <div ng-view></div>
    <script type="text/javascript">
      angular.module('${2:myApp}', ['ui.bootstrap', 'ngRoute', 'ngMockE2E']).config(['$routeProvider', function($routeProvider) {
        $routeProvider.when('/index', {
          templateUrl: 'main.html',
          controller: 'MainCtrl'
        }).otherwise({
          redirectTo: '/index'
        });
      }]).run(function($httpBackend) {
         // hack $http
         $httpBackend.whenPOST('MY_POST_URL').respond(function(method, url, data, headers){
           return [200, {}, {}];
         });
         $httpBackend.whenGET(/^.*/).passThrough();
      }).controller('MainCtrl', ['$scope', function ($scope) {
        $scope.message = 'Hello World';
      }]);
    </script>
  </body>
</html>
